package org.example.interncandidate.service.image.Impl;

import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.LineCaptcha;
import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import kotlin.Result;
import org.example.interncandidate.mapper.image.ImageMapper;
import org.example.interncandidate.mapper.login.LoginMapper;
import org.example.interncandidate.model.image.po.Image;
import org.example.interncandidate.model.image.vo.ImageVO;
import org.example.interncandidate.model.person.po.PersonInfo;
import org.example.interncandidate.service.Redis.Impl.RedisImageServiceImpl;
import org.example.interncandidate.service.image.ImageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ImageServiceImpl extends ServiceImpl<ImageMapper, Image> implements ImageService {
    @Autowired
    private RedisImageServiceImpl redisImageService;
    @Override
    public ImageVO generateCaptchaInfo() {
        LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(200, 100);
        Image image = new Image();
        image.generateImage( lineCaptcha.getCode());
        redisImageService.saveImageByRedis(image);
        return new ImageVO(image.getUid(),lineCaptcha.getImageBase64());
    }
}
